package com.demo.es.controller;

import com.demo.es.common.Page;
import com.demo.es.pojo.dto.UserDTO;
import com.demo.es.pojo.request.QueyUserRequest;
import com.demo.es.pojo.response.PageInfoResponse;
import com.demo.es.service.ElasticSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

/**
 * @author 李炯 es控制层
 * @description: DOTO
 * @program: elastic-demo
 * @date 2020/06/01
 **/
@RestController
@RequestMapping("es")
public class ElasticSearchController {

    @Autowired
    private ElasticSearchService elasticSearchService;

    /**
      * @Description 根据条件分页查询数据,符合条件用户
      * @Author: 李炯
      * @Date: 2020/6/1 10:32
      * @Param: [userRequest]
      * @Return: java.util.List<com.demo.es.pojo.dto.UserDTO>
      * @Exception:
      **/
    @RequestMapping("user")
    public PageInfoResponse<List<UserDTO>> queryUserList(@RequestBody Page<QueyUserRequest> userRequest) throws IOException {
        return elasticSearchService.queryUserList(userRequest);
    }
}
